package com.cnhis.cloudhealth.clidoctorweb.clinewadvice;

import java.util.Map;

import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.cnhis.cloudhealth.clinical.hosdoctor.clinicalpathway.service.IClinicalpathway;
import org.jboss.resteasy.logging.Logger;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.cnhis.cloudhealth.clinical.clidoctor.clinewadvice.service.ICliNewAdvice;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import java.util.HashMap;
import com.cnhis.cloudhealth.commons.interceptor.SpringContextHolder;
import com.cnhis.cloudhealth.commons.redisdb.RedisResource;
import com.cnhis.cloudhealth.commons.utils.JsonUtil;

@Path("clinewadvice")
@Component
public class CliNewAdviceRest
{
    Logger log = Logger.getLogger(CliNewAdviceRest.class);
    
    @Reference
    private ICliNewAdvice iCliNewAdvice;
    @Reference
    IClinicalpathway iClinicalpathway;
    private RedisResource redisResource = (RedisResource) SpringContextHolder.getBean("redisResource");
    
    /**
     * Clinic_EditOrder_before_Judge 医嘱编辑前检查
     * 
     * @param ACF01 业务分类ID2
     * @param VAA01 病人ID
     * @param VAA07 病人业务ID
     * @return
     * @throws Exception
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    @POST
    @Path("cliniceditOrderbeforejudge")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo waitingToReception(@FormParam("ACF01") Integer ACF01, @FormParam("VAA01") Integer VAA01,
        @FormParam("VAA07") Integer VAA07)
            throws Exception
    {
        Map map = new HashMap();
        map.put("ACF01", ACF01);
        map.put("VAA01", VAA01);
        map.put("VAA07", VAA07);
        return iCliNewAdvice.clinicEditOrderBeforeJudge(map);
    }
    
    /**
     * 临床药物评价 Clinic_Drug_Judge
     * 
     * @param lxml xml数据
     * @param ACF01
     * @param VAA01病人id
     * @param VAA07挂号ID
     * @param type 0 门诊医生站 1住院医生站 2住院护士站
     * @param lbce01 医生ID
     * @param upCBM01
     * @param asign 0=暂存 1=确认保存前
     * @return
     * @throws Exception
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    @POST
    @Path("clinicdrugjudge")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo clinicDrugJudge(@FormParam("lxml") String lxml, @FormParam("ACF01") Integer ACF01,
        @FormParam("VAA01") Integer VAA01, @FormParam("VAA07") Integer VAA07, @FormParam("type") Integer type,
        @FormParam("lbce01") Integer lbce01, @FormParam("upCBM01") Integer upCBM01, @FormParam("asign") Integer asign)
            throws Exception
    {
        Map map = new HashMap();
        map.put("lxml", lxml);
        map.put("ACF01", ACF01);
        map.put("VAA01", VAA01);
        map.put("VAA07", VAA07);
        map.put("type", type);
        map.put("lbce01", lbce01);
        map.put("upCBM01", upCBM01);
        map.put("asign", asign);
        return iCliNewAdvice.clinicDrugJudge(map);
    }
    
    /**
     * 新开医嘱 Clinic_VAF1_Insert
     * 
     * @param lVER 版本号
     * @param lXml xml中包括门诊病人医嘱单信息、门诊病人医嘱记录信息、门诊病人诊断记录信息、门诊病人诊疗申请单信息、病人手术人员信息等
     * @param lType 0 门诊医生站 1住院医生站 2住院护士站
     * @param lMode 0:新增 1：修改 2=复诊预约计划
     * @param lCBM01A 修改医嘱单的id
     * @param lACF01 门诊
     * @param lBCK01 科室编号
     * @param lBCE01 医师ID
     * @param lBCE02 编码, 工号, Code
     * @param lBCE03 用户名称
     * @param rCBM 医嘱单信息，多个以逗号分隔 返回值
     * @return
     * @throws Exception
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    @POST
    @Path("clinicvaf1insert")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo clinicVAF1Insert(@FormParam("lver") String lver, @FormParam("lxml") String lxml,
        @FormParam("ltype") Integer ltype, @FormParam("lmode") Integer lmode, @FormParam("lcbm01a") Integer lcbm01a,
        @FormParam("lacf01") Integer lacf01, @FormParam("lbck01") Integer lbck01, @FormParam("lbce01") Integer lbce01,
        @FormParam("lbce02") String lbce02, @FormParam("lbce03") String lbce03, @FormParam("rcbm") String rcbm, @FormParam("proxy") String proxy)
            throws Exception
    {
        Map map = new HashMap();
        map.put("lver", lver);
        map.put("lxml", lxml);
        map.put("ltype", ltype);
        map.put("lmode", lmode);
        map.put("lcbm01a", lcbm01a);
        map.put("lacf01", lacf01);
        map.put("lbck01", lbck01);
        map.put("lbce01", lbce01);
        map.put("lbce02", lbce02);
        map.put("lbce03", lbce03);
        map.put("rcbm", rcbm);
        map.put("proxy", proxy);
        return iCliNewAdvice.clinicVAF1Insert(map);
    }
    // 自定义诊断
    // Clinic_CAM_Insert
    /**
     * 
     * @param lCAM04 名称
     * @param lCAM02 类型
     * @param lCAM03 编码
     * @param ABBRP 拼音
     * @param ABBRW 五笔
     * @return
     * @throws Exception
     */
    
    @SuppressWarnings({"unchecked", "rawtypes"})
    @POST
    @Path("cliniccaminsert")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo clinicCAMInsert(@FormParam("cam1") String cam1)
        throws Exception
    {
        Map map = new HashMap();
        map.put("cam1", cam1);
        return iCliNewAdvice.clinicCAMInsert(map);
    }
    
    /* ScriptId(819) */
    /* Description(获取麻醉项目) */
    @SuppressWarnings({"unchecked", "rawtypes"})
    @GET
    @Path("narcosisitemlist")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo narcosisItemList(@QueryParam("aDate") String aDate)
        throws Exception
    {
        Map map = new HashMap();
        map.put("aDate", aDate);
        return iCliNewAdvice.narcosisItemList(map);
    }
    
    /* ScriptId(7298) */
    /* Description(判断科室是否具有手术性质) */
    /**
     * 
     * @param BCK01 科室id
     * @param BAU01 业务编码
     * @return
     * @throws Exception
     */
    
    @SuppressWarnings({"unchecked", "rawtypes"})
    @POST
    @Path("checkofficeproperty")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo checkOfficeProperty(@FormParam("BCK01") int BCK01, @FormParam("BAU01") String BAU01)
        throws Exception
    {
        Map map = new HashMap();
        map.put("BCK01", BCK01);
        map.put("BAU01", BAU01);
        return iCliNewAdvice.checkOfficeProperty(map);
    }
    
    /* ScriptId(1006) */
    /* Description(获取诊疗项目对应执行科室) */
    @SuppressWarnings({"unchecked", "rawtypes"})
    @POST
    @Path("gettreamentoffice")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getTreamentOffice(@FormParam("BCK01A") int BCK01A, @FormParam("BBX01") int BBX01)
        throws Exception
    {
        Map map = new HashMap();
        map.put("BCK01A", BCK01A);
        map.put("BBX01", BBX01);
        return iCliNewAdvice.getTreamentOffice(map);
    }
    /* ScriptId(7286) */
    /* Description(提取检验类型) */
    /**
     * 
     * @param lACF01 业务id
     * @param lBCE01 员工id
     * @param lDate 日期
     * @return
     * @throws Exception
     */
    
    @SuppressWarnings({"unchecked", "rawtypes"})
    @POST
    @Path("getexaminetype")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getExamineType(@FormParam("lACF01") int lACF01, @FormParam("lBCE01") int lBCE01,
        @FormParam("lDate") String lDate)
            throws Exception
    {
        Map map = new HashMap();
        map.put("lACF01", lACF01);
        map.put("lBCE01", lBCE01);
        map.put("lDate", lDate);
        return iCliNewAdvice.getExamineType(map);
    }
    /* ScriptId(2103) */
    /* Description(科室id获取科室名称) */
    /**
     * 
     * @param BCK01 科室id
     * @return
     * @throws Exception
     */
    
    @SuppressWarnings({"unchecked", "rawtypes"})
    @GET
    @Path("getofficebyid")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getOfficeById(@QueryParam("lBCK01") int lBCK01)
        throws Exception
    {
        Map map = new HashMap();
        map.put("lBCK01", lBCK01);
        return iCliNewAdvice.getOfficeById(map);
    }
    
    /* ScriptId(1547) */
    /* Description(判断此病人是否对此药物过敏) */
    /**
     * @param lVAA01 病人ID
     * @param lBBX01 医疗项目目录ID
     * @param lBBX05
     * @return
     * @throws Exception
     */
    
    @SuppressWarnings({ "unchecked", "rawtypes" })
	@GET
	@Path("guominyaowu")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo getVAL1(@QueryParam("VAA01") long VAA01,
	                       @QueryParam("BBX01") long BBX01,
	                       @QueryParam("BBX05") String BBX05)throws Exception{
	    Map map = new HashMap();
	    map.put("VAA01", VAA01);
	    map.put("BBX01", BBX01);
	    map.put("BBX05", BBX05);
	    return iCliNewAdvice.getVAL1(map);
	}
    
    /* ScriptId() */
    /* Description(查询给药途径列表) */
    /**
     * @param lBDA01 医疗项目类型
     * @param BBX13 执行性质（此处默认为2，标识“给药途径”）
     * @return
     * @throws Exception
     */
    
    @SuppressWarnings({ "rawtypes" })
    @GET
    @Path("geiYaoTuJingList")
    @Produces({ MediaType.APPLICATION_JSON })
    public ModelVo geiYaoTuJingList(@QueryParam("params") String params)throws Exception
    {
        Map map = JsonUtil.getMap(params);
        return iCliNewAdvice.geiYaoTuJingList(map);
    }
    
    /* ScriptId(6899) */
    /* Description(查询诊疗频次列表) */
    /**
     * @param lBDA01 医疗项目类型
     * @param BBX13 执行性质（此处默认为2，标识“给药途径”）
     * @return
     * @throws Exception
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    @GET
    @Path("zhenLiaoPinCiList")
    @Produces({ MediaType.APPLICATION_JSON })
    public ModelVo zhenLiaoPinCiList(@QueryParam("lbdi10") int lbdi10)throws Exception
    {
      //加载redis数据
//        return redisResource.getRedisModelVo("bdi1_xiyao_pinci_mz");
//        从数据库加载
        Map map = new HashMap();
        map.put("lbdi10", lbdi10);
        return iCliNewAdvice.zhenLiaoPinCiList(map);
    }
    /* Description(查询诊疗频次列表) */
    /**
     * @param lBDA01 医疗项目类型
     * @param BBX13 执行性质（此处默认为2，标识“给药途径”）
     * @return
     * @throws Exception
     */
    
    @GET
    @Path("zhongyaoJiaozhu")
    @Produces({ MediaType.APPLICATION_JSON })
    public ModelVo zhongyaoJiaozhu()throws Exception
    {
        
      //加载redis数据
//        return redisResource.getRedisModelVo("acx1_zhongyaojiaozhu_mz");
        //加载从数据库
        Map map = new HashMap();
        return iCliNewAdvice.zhongyaoJiaozhu(map);
    }

    /* ScriptId(null) 获取手术附加项目*/
    @SuppressWarnings("unchecked")
    @GET
    @Path("getOperationpro")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getOperationpro() throws Exception{
      //加载redis数据
//        return redisResource.getRedisModelVo("bbx1_fujiashoushu_mz");
//        从数据库加载
        return iCliNewAdvice.getOperationpro();
    }

    /* ScriptId(null) 获取手术麻醉项目*/
    @GET
    @Path("getAnaesthesiaItem")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getAnaesthesiaItem() throws Exception{
      //加载redis数据
//        return redisResource.getRedisModelVo("bbx1_mazui_mz");
        //从数据库加载
        return iCliNewAdvice.getAnaesthesiaItem();
    }
    
    /* ScriptId(null) 获取手术麻醉项目*/
    @GET
    @Path("zhongyaoyongfa")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo zhongyaoyongfa() throws Exception{
      //加载redis数据
//        return redisResource.getRedisModelVo("bbx1_zhongyaoyongfa_mz");
//        查询数据库
        return iCliNewAdvice.zhongyaoyongfa();
    }
    
    /* ScriptId(null) 获取用药目的*/
    @GET
    @Path("getYongyaomudiList")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getYongyaomudiList() throws Exception{
      //加载redis数据
//        return redisResource.getRedisModelVo("biw1_yongyaomudi_mz");
        //从数据库加载
        return iCliNewAdvice.getYongyaomudiList();
    }
    
    /* ScriptId(null) 获取手术人员列表*/
    @GET
    @Path("shoushurenyuanList")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo shoushurenyuanList() throws Exception{
        
        //加载redis数据
//        return redisResource.getRedisModelVo("bce1_shoushurenyuan_mz");
        //从数据库加载
        return iCliNewAdvice.shoushurenyuanList();
    }
}
